/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package com.mycompany.delivery.entities;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.OneToMany;

/**
 *
 * @author Martin Huněk
 */
@Entity
public class Employee extends User implements Serializable {
    
   @OneToMany(fetch= FetchType.EAGER, mappedBy = "employee")
    private Set<Delivery> createdDelivery = new HashSet<Delivery>();

    public Set<Delivery> getCreatedDelivery() {
        return createdDelivery;
    }

    public void setCreatedDelivery(Set<Delivery> createdDelivery) {
        this.createdDelivery = createdDelivery;
    }

    @Override
    public String toString() {
        return "Employee{" + "id=" + getId() + ", login=" + getLogin() + ", contact=" + getContact() + ", deliveries=" + createdDelivery + '}';
    }
    
    public void addDelivery(Delivery delivery) {
        createdDelivery.add(delivery);
    }
    
    
      public void removeDelivery(Delivery delivery) {
        createdDelivery.remove(delivery);
    }
    
}
